const http = require("http");
const msbd = require("./msbd");
const route = require("./route")
var querystring = require("querystring")
const url = require("url");

http.createServer(function (request, response) {
    var pathname = url.parse(request.url).pathname;
    route(pathname)
    response.writeHead(200, { "Content-Type": "text/html;charset=UTF-8" });
    // 模块系统
    // console.log(msbd)

    // 获取GET请求内容
    // var params = url.parse(request.url, true).query;
    // console.log(params)
    // console.log(request)
    //获取POST请求内容
    let post = ""
    request.on("data", function (chunk) {
        post += chunk
    })

    request.on("end", function () {
        post = querystring.parse(post);
        console.log(post)
    })
    response.end("hello world")
}).listen(8888)